﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using Microsoft.Practices.Composite;
using Microsoft.Practices.Unity;
using XClient.Infrastructure;
using XClient.Interfaces;
using XClient.ViewModels;

namespace XClient.Views
{
    /// <summary>
    /// Interaction logic for ChatView.xaml
    /// </summary>
    public partial class ChatView : UserControl, IChatView, IActiveAware
    {
        #region · Fields ·

        private ChatViewModel   viewModel;
        private IUnityContainer container;
        private int             viewerHeight;

        #endregion

        #region · IActiveAware Members ·

        event EventHandler IActiveAware.IsActiveChanged
        {
            add { throw new NotImplementedException(); }
            remove { throw new NotImplementedException(); }
        }

        public bool IsActive
        {
            get { return this.viewModel.IsActive; }
            set { this.viewModel.IsActive = value; }
        }

        #endregion

        #region · Properties ·

        public ChatViewModel ViewModel
        {
            get { return this.viewModel; }
            set
            {
                this.viewModel = value;
                this.DataContext = value;
            }
        }

        #endregion
        
        #region · Constructors ·

        public ChatView(IUnityContainer container)
        {
            InitializeComponent();

            this.container          = container;
            this.viewerHeight       = 0;
        }

        #endregion

        #region · Event Handlers ·

        private void Message_PreviewKeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == System.Windows.Input.Key.Return)
            {
                e.Handled = true;
                //this.ViewModel.SendMessage(this.Message.GetText());
                //this.Message.Document.Blocks.Clear();
            }
        }

        #endregion
    }
}
